﻿namespace VividKit.ComponentModel
{
    using System;
    using VividKit.PresentationModel.Navigation;
    using Windows.UI.Xaml.Controls;

    public class TabletServiceProvider : ServiceProviderBase
    {
        private readonly IDispatcher dispatcher;
        private readonly ICommandManager commandManager;
        private readonly INavigationService navigationService;

        public TabletServiceProvider(Frame frame)
        {
            this.dispatcher = new Dispatcher();
            this.commandManager = new DefaultCommandManager(this.dispatcher);
            this.navigationService = new FrameNavigationService(frame);
        }

        private TabletServiceProvider()
        {
        }

        protected override object GetServiceOverride(Type serviceType)
        {
            if (serviceType == typeof(IDispatcher))
            {
                return this.dispatcher;
            }
            if (serviceType == typeof(ICommandManager))
            {
                return this.commandManager;
            }
            if (serviceType == typeof(INavigationService))
            {
                return this.navigationService;
            }

            return null;
        }
    }
}